# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=higan
pkgver=110
pkgrel=2
pkgdesc='A multi-system emulator focused on accuracy, preservation, and configurability'
arch=(loong64 x86_64)
url=https://byuu.org/
license=(GPL3)
depends=(
  gcc-libs
  glibc
  libao
  libasound.so
  libgl
  libpulse-simple.so
  libpulse.so
  libudev.so
  libx11
  libxext
  libxrandr
  libxv
  openal
  qt5-base
  sdl2
)
makedepends=(
  git
)
source=(
  git+https://github.com/byuu/higan.git#tag=483c5781fc7e853d6ae9f179303cca16af09134f
  higan-flags.patch
  higan-paths.patch
)
sha256sums=('SKIP'
            'bf84cfa9f2499a187dca613272fadf267fd3e2c29b615af74b1e219bd8c3247c'
            '9cc20274c420a05667f35bdc9db313f1a6ce47d964dbf0cef62d85c46a4170a4')

pkgver() {
  cd higan

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd higan

  patch -Np1 -i ../higan-flags.patch
  patch -Np1 -i ../higan-paths.patch
  sed 's|/usr/local/lib/qt5/bin/moc|moc|' -i hiro/GNUmakefile
}

build() {
  cd higan

  make -C higan hiro=qt5
  make -C icarus hiro=qt5
}

package() {
  install -dm 755 "${pkgdir}"/usr/share/{higan,icarus}

  install -Dm 755 higan/higan/out/higan -t "${pkgdir}"/usr/bin/
  install -Dm 644 higan/higan/target-higan/resource/higan.desktop -t "${pkgdir}"/usr/share/applications/
  install -Dm 644 higan/higan/target-higan/resource/higan.svg -t "${pkgdir}"/usr/share/pixmaps/
  cp -dr --no-preserve='ownership' higan/higan/System "${pkgdir}"/usr/share/higan/Templates

  install -Dm 755 higan/icarus/out/icarus -t "${pkgdir}"/usr/bin/
  install -Dm 644 higan/icarus/data/icarus.desktop -t "${pkgdir}"/usr/share/applications/
  install -Dm 644 higan/icarus/data/icarus.svg -t "${pkgdir}"/usr/share/pixmaps/
  cp -dr --no-preserve='ownership' higan/icarus/Database higan/icarus/Firmware "${pkgdir}"/usr/share/icarus/
}

# vim: ts=2 sw=2 et:
